export default class Print {
  constructor(name, data, option) {
    this.name = name;
    this.data = data;
    this.seriesData = [];
    this.option = option;
  }

  generateData() {
    let data = this.data;
    this.seriesData = data.map(item => {
      return {
        name: item.name,
        value: [item.lng, item.lat, 40],
        symbolSize: 18,
        itemStyle: {
          normal: {
            color: item.state == 1 ? "#08ED74" : "red"
          }
        },
        tooltip: {
          formatter: params => {
            return `${params.marker} ${params.name}`;
          }
        }
      };
    });
  }

  generateOption() {
    this.option.geo.map = this.name;
    this.option.geo.zoom = 1;
    this.option.series = [];
    this.option.tooltip = {
      trigger: "item",
      // backgroundColor: "rgba(12, 204, 104, 0.92)",
      borderColor: "#FFFFCC",
      showDelay: 0,
      hideDelay: 0,
      padding: 10,
      enterable: true,
      transitionDuration: 0,
      extraCssText: "z-index:100",
      formatter: params => params.name
    };
    this.option.series.push({
      name: "企业名称",
      type: "effectScatter",
      coordinateSystem: "geo",
      data: this.seriesData,
      hoverAnimation: true,
      zlevel: 2,
      rippleEffect: {
        brushType: "stroke"
      },
      label: {
        normal: {
          formatter: "{b}",
          position: "right",
          show: true
        }
      },
      showEffectOn: "render"
    });
  }

  start() {
    this.generateData();
    this.generateOption();
    return this.option;
  }
}
